{extend name="index_layout"/}
{block name="main"}
<div class="layui-card">
    <div class="layui-card-header">用户管理</div>
    <div class="layui-card-body">
        <div class="layui-form">
            <table class="layui-hide" id="currentTable" lay-filter="currentTable"
                   data-auth-add="{:$auth->check('member/add')}"
                   data-auth-edit="{:$auth->check('member/edit')}"
                   data-auth-delete="{:$auth->check('member/del')}"
                   data-auth-recyclebin="{:$auth->check('member/recyclebin')}"
            ></table>
        </div>
    </div>
</div>
<script type="text/html" id="barTool">
    <a data-open='{:url("edit")}?id={{ d.id }}'
       class="layui-btn layui-btn-xs {:$auth->check('member/edit')?'':'layui-hide'}" title="扣除保证金">扣除保证金</a>

    <a href='{:url("del")}?id={{ d.id }}'
       class="layui-btn layui-btn-danger layui-btn-xs layui-tr-del {:$auth->check('item/del')?'':'layui-hide'}"><i
            class='iconfont icon-trash_fill'></i></a>
</script>

<script type="text/html" id="member_bill">
    <a data-open='{:url("/admin/member_bill/index")}?id={{ d.id }}'
       class="layui-btn layui-btn-xs {:$auth->check('member/edit')?'':'layui-hide'}" title="收入记录">收入记录</a>

</script>

{/block}
{block name="script"}
<script type="text/javascript">
    layui.use('yznTable', function () {
        var table = layui.yznTable;

        var init = {
            table_elem: '#currentTable',
            table_render_id: 'currentTable',
            add_url: '{:url("add")}',
            edit_url: '{:url("edit")}',
            delete_url: '{:url("del")}',
            modify_url: "{:url('multi')}",
            recyclebin_url: "{:url('recyclebin')}",
        };


        var vip = <?php echo $vip; ?>;
        var advise = <?php echo $advise; ?>;

        table.render({
            init: init,
            toolbar: ['refresh', 'delete'],
            url: '{:url("index")}',
            cols: [
                [
                    {type: 'checkbox', fixed: 'left'},
                    {field: 'id', align: 'center', title: '用户ID', minWidth: 120},
                    {
                        field: 'avatar',
                        align: 'center',
                        title: '头像',
                        search: false,
                        minWidth: 110,
                        templet: yznTable.formatter.image
                    },
                    {field: 'nickname', align: 'center', title: '用户昵称',  searchOp: 'LIKE', minWidth: 140},
                    {field: 'phone', align: 'center', title: '手机号',  searchOp: 'LIKE', minWidth: 140},
                    {
                        field: 'vip_name',
                        align: 'center',
                        fieldAlias:'vip_type',
                        title: 'vip类型',
                        minWidth: 140,
                        templet: yznTable.formatter.label,
                        selectList:vip
                    },
                    {
                        field: 'vip_expire_time',
                        title: '过期时间',
                        minWidth: 80,
                        align: 'center',
                        width: 180,
                        search: false,
                        templet: yznTable.formatter.datetime
                    },
                    {
                        field: 'advise_name',
                        title: '财税顾问',
                        fieldAlias:'advise_level',
                        align: 'center',
                        width: 120,
                        templet: yznTable.formatter.label,
                        selectList:advise
                    },
                    {
                        field: 'bond',
                        title: '保证金',
                        minWidth: 80,
                        search: false,
                        align: 'center',
                        width: 180,
                    },
                    {
                        field: 'member_bill',
                        title: '收入记录',
                        minWidth: 80,
                        search: false,
                        align: 'center',
                        width: 180,
                        toolbar: '#member_bill'
                    },
                    {
                        field: 'source',
                        title: '来源',
                        minWidth: 80,
                        align: 'center',
                        width: 180,
                        templet: yznTable.formatter.status,
                        selectList: {0: '自搜索', 1: '团队分销', 2: '财税顾问分销'},
                    },
                    {
                        field: 'user.nickname',
                        title: '上级',
                        minWidth: 80,
                        align: 'center',
                        width: 180,
                    },
                    {
                        field: 'advise_total_money',
                        title: '财税顾问钱包余额',
                        minWidth: 80,
                        align: 'center',
                        width: 180,
                        search: false,
                    },
                    {
                        field: 'team_total_money',
                        title: '团队分销钱余额',
                        minWidth: 80,
                        align: 'center',
                        width: 180,
                        search: false,
                    },
                    {
                        field: 'status',
                        align: 'center',
                        width: 120,
                        title: '状态',
                        unresize: true,
                        templet: yznTable.formatter.switch,
                        tips: "显示|隐藏",
                        selectList: {0: '冻结', 1: '正常'},
                    }, {
                    field: 'create_time',
                    title: '创建时间',
                    minWidth: 80,
                    width: 180,
                    search: false,
                    templet: yznTable.formatter.datetime
                },
                    {fixed: 'right', align: 'center', width: 220, title: '操作', toolbar: '#barTool'}
                ]
            ],
            page: {}
        });

        yznTable.bindevent();
    });
</script>
{/block}